﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Sockets;
using System.Net;
using System.Threading;
using Lidgren.Network;
using Zombie_Demo.Comm;

namespace Zombie_Demo_Server
{
    class Program
    {
        private static NetServer server;
        private static NetPeerConfiguration config;

        public Program()
        {
            config = new NetPeerConfiguration("ZD_Server");
            config.Port = 13377;
            config.MaximumConnections = 200;
            config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);

            server = new NetServer(config);

            server.Start();
            Console.WriteLine("Server started at port: " + config.Port.ToString());

            NetIncomingMessage inc;
            DateTime time = DateTime.Now;
            TimeSpan timeToPass = new TimeSpan(0, 0, 0, 0, 30);

            Console.WriteLine("Waiting for connections and updating world state to current ones.");

            while (true)
            {
                if ((inc = server.ReadMessage()) != null)
                {
                    switch (inc.MessageType)
                    {
                        case NetIncomingMessageType.ConnectionApproval:
                            if (inc.ReadByte() == (byte)Protocols.PacketTypes.LOGIN)
                            {

                            }
                            break;
                    }
                }
            }
        }
    }
}
